package com.junzhiit.nengji.shop.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.bainaeco.framework.base.dao.AbstractBaseDAO;
import com.bainaeco.framework.common.jdbc.StatementParameter;
import com.junzhiit.nengji.shop.dao.ChainGoodsSystemTypeDAO;
import com.junzhiit.nengji.shop.model.ChainGoodsSystemType;
import com.junzhiit.nengji.shop.model.enums.Is;

@Repository
public class ChainGoodsSystemTypeDAOImpl extends AbstractBaseDAO<ChainGoodsSystemType> implements ChainGoodsSystemTypeDAO{
	@Override
	public List<String> getGoodsSystemTypeByChainGoodsId(String Id) {
		StringBuffer sql = new StringBuffer();
		StatementParameter params = new StatementParameter();
		sql.append("select system_type_id from chain_goods_system_type where chain_goods_id = ? and is_delete = ? ");
		params.setString(Id);
		params.setInt(Is.NO.toIntValue());
		return super.queryForStrings(sql.toString(), params);
	}

	
	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public boolean deleteByChainGoodsId(String ChainGoodsId) {
		StringBuffer sql = new StringBuffer();
		sql.append("delete from chain_goods_system_type where chain_goods_id=?");
		
		StatementParameter params=new StatementParameter();
		params.setString(ChainGoodsId);
		
		return super.updateForBoolean(sql.toString(), params);
	}
	
	@Override
	public List<ChainGoodsSystemType> findByChainGoodsId(String ChainGoodsId){
		StringBuffer sql=new StringBuffer();
		sql.append("select * from chain_goods_system_type where chain_goods_id=?");
		
		StatementParameter params=new StatementParameter();
		params.setString(ChainGoodsId);
		
		return super.queryForList(sql.toString(), ChainGoodsSystemType.class,params);
	}

}
